package com.service;

import com.tools.SaveData;
import redis.clients.jedis.Jedis;

public class RedisUtils {
    public static void main(String[] args) {
//        RedisUtils redisUtils = new RedisUtils();
//        redisUtils.getUserProfile(4027);
        SaveData saveData = new SaveData();
        saveData.saveMovieTag();
//        saveData.saveRat();
//        saveData.saveMovie();
    }

    public void getUserProfile(int uid) {
        Jedis jedis = new Jedis("localhost");
        float[] scoreArray = new float[1130];
        String[] temp;
        String str = jedis.hget("fr:uid:" + uid, "5.0");
        temp = str.split(",");
        for (String s : temp) {

            for (int i = 1; i < 1129; i++) {
                String tempTagStr = jedis.hget("fr:mid:" + s, "" + i);
                if ("".equals(tempTagStr) || tempTagStr == null) {
                    continue;
                }
                scoreArray[i] += Float.parseFloat(tempTagStr);
            }
        }

        for (int i = 1; i < 1129; i++) {
            System.out.println("id:" + i + "  " + scoreArray[i]);
        }
    }
}
